#include <SGE.h>

using namespace SGE;

bool quit = false; //replaces hard coded false to quite game

SGE_Sprite sprite;

//2 dimensional vector has an x and y, good to store position
SVector2 position;

void SGE_Initialize()
{
	//by default, loader looks in VGP230//Data//Textures
	sprite.Load("Impa.jpg");
}

void SGE_Terminate()
{
	//does not need parameters as it unloads whatever it has
	sprite.Unload();
}

//boolean monitors when to break out of this loop (return true to terminate)
bool SGE_Update(float deltaTime) //DELTA TIME - measure of how much time has passed since we last called this function
{

	const float kSpeed = 100.0f; //100 pixels moved within a second

	//right-left movement
	if(Input_IsKeyDown(Keys::RIGHT))
	{
		//position.x += 1.0f;

		position.x += kSpeed * deltaTime; //if right key held down, move 1 pixel over for each update
	}
	else if(Input_IsKeyDown(Keys::LEFT))
	{
		position.x -= kSpeed * deltaTime; //else if left key held down, move 1 pixel to the left for each update
	}

	//up-down movement
	if(Input_IsKeyDown(Keys::UP))
	{
		position.y -= kSpeed * deltaTime; //negative to go up because coordinate system is top down, (0,0) is top left corner
	}
	else if(Input_IsKeyDown(Keys::DOWN))
	{
		position.y += kSpeed * deltaTime;
	}

	//virtual key codes: included in Input.h (accessed using Keys namespace)
	if(Input_IsKeyPressed(Keys::ESCAPE)) 
	{
		quit = true;
	}

	return quit;
}

void SGE_Render()
{
	//move to 'position' before rendering
	sprite.SetPosition(position);

	//render sprite we've created
	sprite.Render();
}